#pragma once

#include "serial.hpp"

#if OS==OS_UNIX

#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <termios.h>

class UnixSerial : public Serial
{
public:
	UnixSerial(
		const char* port = "",
		uint32_t baudrate = DEFAULT_BAUD_RATE,
		uint8_t databits = DEFAULT_DATA_BITS,
		uint8_t parity = DEFAULT_PARITY,
		uint8_t stopbits = DEFAULT_STOP_BITS,
		uint8_t flowCtrl = DEFAULT_FLOW_CTRL
		);
	~UnixSerial();
	virtual bool config();
	virtual bool open();
	virtual bool close();
	virtual uint32_t tx(uint8_t* data, uint32_t len);
	virtual uint32_t rx(uint8_t* data, uint32_t len);
protected:
	struct termios newio;
	int fd;
};

#endif

